package com.CRApp.exception;

import ch.qos.logback.core.util.StringUtil;
import com.CRApp.pojo.Result;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName: GlobalExceptionHandler
 * @Author : LuoFan洛樊
 * @Date : 2025/2/6 - 0:03
 * Description : TODO
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result HandleException(Exception e){
        e.printStackTrace();
        return Result.error(StringUtils.hasLength(e.getMessage())?e.getMessage():"服务器异常");
    }
}
